package cn.edu.neu.studentmsg_java.service.impl;

import cn.edu.neu.studentmsg_java.dao.AppointmentDao;
import cn.edu.neu.studentmsg_java.dao.TRDao;
import cn.edu.neu.studentmsg_java.dao.TeacherDao;
import cn.edu.neu.studentmsg_java.model.Teacher;
import cn.edu.neu.studentmsg_java.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao teacherDao;
    @Autowired
    private TRDao trdao;
    @Autowired
    private AppointmentDao appointmentDao;
    @Override
    public List<Teacher> findTeacherPart(Teacher teacher) {
        return teacherDao.selectTeacherPart(teacher);
    }

    @Override
    public int removeTeacherById(Integer teacher_id) {
        //需要先删除授课表中的信息
        appointmentDao.deleteAppointmentByTeacherId(teacher_id);
        return teacherDao.deleteTeacherById(teacher_id);
    }

    @Override
    public int addTeacher(Teacher teacher) {
//        teacher.setRank_id(trdao.selectRankIdByRankName(teacher.getRank_name()));
        return teacherDao.insertTeacher(teacher);
    }

    @Override
    public int modifyTeacherById(Teacher teacher) {
        return teacherDao.updateTeacherById(teacher);
    }

    @Override
    public List<String> findTeacherName() {
        return teacherDao.selectTeacherName();
    }

    @Override
    public Teacher findTeacherByTeacherId(Integer teacher_id) {
        return teacherDao.selectTeacherByTeacherId(teacher_id);
    }

    @Override
    public String findTeacherNameByTeacherId(Integer teacher_id) {
        return teacherDao.selectTeacherNameByTeacherId(teacher_id);
    }
}
